﻿using Microsoft.Xna.Framework;

namespace Heightmap_Editor.Menu.Screens
{
    class MainMenu : MenuScreen
    {
        public MainMenu() : base("Main Menu")
        {
            MenuEntry newMap = new MenuEntry("New Map");
            MenuEntry openMap = new MenuEntry("Open Map");
            MenuEntry saveMap = new MenuEntry("Save Map");
            MenuEntry exit = new MenuEntry("Exit");

            exit.Selected += exit_Selected;
            newMap.Selected += newMap_Selected;
            saveMap.Selected += saveMap_Selected;
            openMap.Selected += openMap_Selected;

            MenuEntries.Add(newMap);
            MenuEntries.Add(openMap);
            MenuEntries.Add(saveMap);
            MenuEntries.Add(exit);
        }

        void openMap_Selected(object sender, GameStateManagement.PlayerIndexEventArgs e)
        {
            ScreenManager.AddScreen(new ImportScreen(), PlayerIndex.One);
        }

        void saveMap_Selected(object sender, GameStateManagement.PlayerIndexEventArgs e)
        {
            ScreenManager.AddScreen(new ExportScreen(), PlayerIndex.One);
        }

        void newMap_Selected(object sender, GameStateManagement.PlayerIndexEventArgs e)
        {
            ScreenManager.AddScreen(new NewMap(), PlayerIndex.One);
        }

        void exit_Selected(object sender, GameStateManagement.PlayerIndexEventArgs e)
        {
            HeightmapEditor.Instance.Exit();
        }
    }
}
